<template>
  <el-container class="admin-container">
    <el-aside width="220px" class="admin-aside">
      <div class="admin-logo">
        <router-link to="/">E-Commerce</router-link>
      </div>
      <el-menu
        :default-active="$route.path"
        class="admin-menu"
        router
        :collapse="isCollapse"
      >
        <el-menu-item index="/admin/dashboard">
          <el-icon><DataLine /></el-icon>
          <span>数据总览</span>
        </el-menu-item>
        <el-menu-item index="/admin/products">
          <el-icon><Goods /></el-icon>
          <span>商品管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/users">
          <el-icon><User /></el-icon>
          <span>用户管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/orders">
          <el-icon><Tickets /></el-icon>
          <span>订单管理</span>
        </el-menu-item>
        <el-menu-item index="/admin/shipping">
          <el-icon><Box /></el-icon>
          <span>配送管理</span>
        </el-menu-item>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header class="admin-header">
        <div class="header-left">
           <!-- Can add breadcrumbs or other controls here -->
        </div>
        <div class="header-right">
          <el-dropdown>
            <span class="el-dropdown-link">
              Admin<el-icon class="el-icon--right"><arrow-down /></el-icon>
            </span>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item>个人中心</el-dropdown-item>
                <el-dropdown-item divided>退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
        </div>
      </el-header>
      <el-main class="admin-main">
        <router-view :key="$route.fullPath" />
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import {
  DataLine,
  Goods,
  User,
  Tickets,
  ArrowDown,
  Box
} from '@element-plus/icons-vue';

const isCollapse = ref(false);
</script>

<style scoped>
.admin-container {
  height: 100vh;
}
.admin-aside {
  background-color: #304156;
  transition: width 0.28s;
  color: #fff;
}
.admin-logo {
  height: 60px;
  line-height: 60px;
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  background-color: #2b2f3a;
}
.admin-logo a {
  color: #fff;
  text-decoration: none;
}
.admin-menu:not(.el-menu--collapse) {
  width: 220px;
}
.admin-menu {
  border-right: none;
  background-color: #304156;
}
.el-menu-item {
  color: #bfcbd9;
}
.el-menu-item:hover {
  background-color: #263445 !important;
}
.el-menu-item.is-active {
  color: #409eff !important;
  background-color: #263445 !important;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,21,41,.08);
}
.header-right {
  display: flex;
  align-items: center;
}
.el-dropdown-link {
  cursor: pointer;
  display: flex;
  align-items: center;
}

.admin-main {
  background-color: #f0f2f5;
  padding: 20px;
}

/* fade-transform, comment out for now to fix table alignment issues
.fade-transform-leave-active,
.fade-transform-enter-active {
  transition: all .5s;
}
.fade-transform-enter-from {
  opacity: 0;
  transform: translateX(-30px);
}
.fade-transform-leave-to {
  opacity: 0;
  transform: translateX(30px);
}
*/
</style> 